/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import interfaces.IItem;
/**
 *
 * @author luk
 */
public class ItemInteger implements IItem{
    int val;
    public ItemInteger(int val){
        this.val = val;
    }
    
    @Override
    public int compareTo(Object other){
        try{
            ItemInteger o = (ItemInteger)other;
            if (val<o.val) 
                return -1;
            else if (val>o.val)
                return 1;
            else
                return 0;
        }
        catch(Exception ex){
            ex.printStackTrace();
            return -1;
        }
    }
    
    @Override
    public int hashCode(){
        return val;
    }
    
    @Override
    public boolean equals(Object obj){
        ItemInteger other = ( obj instanceof ItemInteger ? (ItemInteger)obj : null );
        if (other==null)
            return false;
        
        boolean eq = (this.val==other.val);
        return eq;
    }
    
    @Override
    public String toString(){
        return Integer.toString(val);
    }
}
